package com.stars.system.reim.domain;

import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.exception.ServiceException;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Date;
import java.util.List;

/**
 * 报销统计记录对象 stars_reim_stat
 * 
 * @author shuaibizhe
 * @date 2023-01-19
 */
public class ReimDailyStatVO extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 统计id */
    private String statId;

    /** 统计日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "统计日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date statDate;

    /** 统计信息 */
    @Excel(name = "统计信息")
    private List<ReimDailyStatInfo> statInfo;

    public String getStatId()
    {
        return statId;
    }

    public Date getStatDate()
    {
        return statDate;
    }

    public List<ReimDailyStatInfo> getStatInfo()
    {
        return statInfo;
    }

    public ReimDailyStatVO buildReimStat(ReimDailyStat reimStat) {
        this.statId = reimStat.getStatId();
        this.statDate = reimStat.getStatDate();
        try {
            this.statInfo = JSONArray.parseArray(reimStat.getStatInfo(), ReimDailyStatInfo.class);
        } catch (Exception e) {
            throw new ServiceException("访问出错了，请联系管理员");
        }
        return this;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("statId", getStatId())
            .append("statDate", getStatDate())
            .append("statInfo", getStatInfo())
            .append("createBy", getCreateBy())
            .append("createTime", getCreateTime())
            .toString();
    }
}
